basedir:=..
antlr:=antlr
srcdir:=.
pathhere:=parse
objdir:=$(basedir)/obj/$(pathhere)

CXX = ccache g++
COMPILEFLAGS = -Wall -I/usr/local/include -g
LINKFLAGS = -L/usr/local/lib -lantlr


lexerobjnames:=PlantainLexer.o
lexerobjfiles:=$(addprefix $(objdir)/, $(lexerobjnames))

parserobjnames:=PlantainParser.o
parserobjfiles:=$(addprefix $(objdir)/, $(parserobjnames))

allobjfiles:=$(parserobjfiles) $(lexerobjfiles)

parsersrcfiles :=  PlantainParser.cpp PlantainParser.hpp  

lexersrcfiles := PlantainLexer.cpp PlantainLexer.hpp PlantainTokenTypes.txt

all: $(allobjfiles)

$(parsersrcfiles): grammar.g $(lexersrcfiles)
	$(antlr) -o $(srcdir) grammar.g 

$(lexersrcfiles): lexer.g 
	$(antlr) -o $(srcdir) lexer.g

$(objdir)/%.o: %.cpp 
	$(CXX) -c $< -o $@ $(COMPILEFLAGS)

check: all
	$(MAKE) -C test check 

clean: 
	-rm $(allobjfiles) $(executables)
